Skip to content

Conversation

@YuriPlyakhin
Copy link
Contributor

No description provided.

@github-actions
Copy link

github-actions bot commented Nov 24, 2025

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff origin/main HEAD --extensions c,h,cpp -- clang/test/Driver/linker-wrapper-image.c llvm/include/llvm/Object/OffloadBinary.h llvm/include/llvm/ObjectYAML/OffloadYAML.h llvm/lib/Frontend/Offloading/OffloadWrapper.cpp llvm/lib/Object/Binary.cpp llvm/lib/Object/OffloadBinary.cpp llvm/lib/ObjectYAML/OffloadEmitter.cpp llvm/lib/ObjectYAML/OffloadYAML.cpp llvm/tools/obj2yaml/offload2yaml.cpp --diff_from_common_commit

⚠️
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing origin/main to the base branch/commit you want to compare against.
⚠️

View the diff from clang-format here.
diff --git a/llvm/include/llvm/Object/OffloadBinary.h b/llvm/include/llvm/Object/OffloadBinary.h
index e7db4a71c..5a9b4120d 100644
--- a/llvm/include/llvm/Object/OffloadBinary.h
+++ b/llvm/include/llvm/Object/OffloadBinary.h
@@ -88,7 +88,7 @@ public:
   struct Header {
     uint8_t Magic[4] = {0x10, 0xFF, 0x10, 0xAD}; // 0x10FF10AD magic bytes.
     uint32_t Version = OffloadBinary::Version;   // Version identifier.
-    uint64_t Size;        // Size in bytes of this entire binary.
+    uint64_t Size;          // Size in bytes of this entire binary.
     uint64_t EntriesOffset; // Offset in bytes to the start of entries block.
     uint64_t EntriesCount;  // Number of metadata entries in the binary.
   };
@@ -162,7 +162,8 @@ private:
         reinterpret_cast<const StringEntry *>(&Buffer[TheEntry->StringOffset]);
     for (uint64_t I = 0, E = TheEntry->NumStrings; I != E; ++I) {
       StringRef Key = &Buffer[StringMapBegin[I].KeyOffset];
-      StringData[Key] = StringRef(&Buffer[StringMapBegin[I].ValueOffset], StringMapBegin[I].ValueSize);
+      StringData[Key] = StringRef(&Buffer[StringMapBegin[I].ValueOffset],
+                                  StringMapBegin[I].ValueSize);
     }
   }
 

@github-actions
Copy link

github-actions bot commented Nov 24, 2025

🐧 Linux x64 Test Results

  • 96935 tests passed
  • 1803 tests skipped
  • 5 tests failed

Failed Tests

(click on a test name to see its output)

Clang

Clang.Driver/linker-wrapper-hip-amdgcnspirv.c
Exit Code: 2

Command Output (stdout):
--
# RUN: at line 1
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Driver/linker-wrapper-hip-amdgcnspirv.c -triple "spirv64-amd-amdhsa" -emit-llvm-bc -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper-hip-amdgcnspirv.c.tmp.bc
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Driver/linker-wrapper-hip-amdgcnspirv.c -triple spirv64-amd-amdhsa -emit-llvm-bc -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper-hip-amdgcnspirv.c.tmp.bc
# note: command had no output on stdout or stderr
# RUN: at line 2
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/llvm-offload-binary -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper-hip-amdgcnspirv.c.tmp.out "--image=file=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper-hip-amdgcnspirv.c.tmp.bc,triple=spirv64-amd-amdhsa,arch=amdgcnspirv,kind=hip"
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/llvm-offload-binary -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper-hip-amdgcnspirv.c.tmp.out --image=file=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper-hip-amdgcnspirv.c.tmp.bc,triple=spirv64-amd-amdhsa,arch=amdgcnspirv,kind=hip
# note: command had no output on stdout or stderr
# RUN: at line 3
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang-linker-wrapper      "--should-extract=amdgcnspirv"      "--host-triple=spirv64-amd-amdhsa"      "--linker-path=clang-offload-bundler"      "--emit-fatbin-only"      "-o" "/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper-hip-amdgcnspirv.c.tmp.hipfb"      "/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper-hip-amdgcnspirv.c.tmp.out"      --dry-run  2>&1 | /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Driver/linker-wrapper-hip-amdgcnspirv.c
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang-linker-wrapper --should-extract=amdgcnspirv --host-triple=spirv64-amd-amdhsa --linker-path=clang-offload-bundler --emit-fatbin-only -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper-hip-amdgcnspirv.c.tmp.hipfb /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper-hip-amdgcnspirv.c.tmp.out --dry-run
# note: command had no output on stdout or stderr
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Driver/linker-wrapper-hip-amdgcnspirv.c
# .---command stderr------------
# | FileCheck error: '<stdin>' is empty.
# | FileCheck command line:  /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Driver/linker-wrapper-hip-amdgcnspirv.c
# `-----------------------------
# error: command failed with exit status: 2

--

Clang.Driver/linker-wrapper-hip-no-rdc.c
Exit Code: 2

Command Output (stdout):
--
# RUN: at line 11
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Driver/linker-wrapper-hip-no-rdc.c -triple amdgcn-amd-amdhsa -emit-llvm-bc -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper-hip-no-rdc.c.tmp.amdgpu.bc
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Driver/linker-wrapper-hip-no-rdc.c -triple amdgcn-amd-amdhsa -emit-llvm-bc -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper-hip-no-rdc.c.tmp.amdgpu.bc
# note: command had no output on stdout or stderr
# RUN: at line 12
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/llvm-offload-binary -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper-hip-no-rdc.c.tmp.out    --image=file=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper-hip-no-rdc.c.tmp.amdgpu.bc,kind=hip,triple=amdgcn-amd-amdhsa,arch=gfx9-4-generic:xnack+    --image=file=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper-hip-no-rdc.c.tmp.amdgpu.bc,kind=hip,triple=amdgcn-amd-amdhsa,arch=gfx1200
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/llvm-offload-binary -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper-hip-no-rdc.c.tmp.out --image=file=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper-hip-no-rdc.c.tmp.amdgpu.bc,kind=hip,triple=amdgcn-amd-amdhsa,arch=gfx9-4-generic:xnack+ --image=file=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper-hip-no-rdc.c.tmp.amdgpu.bc,kind=hip,triple=amdgcn-amd-amdhsa,arch=gfx1200
# note: command had no output on stdout or stderr
# RUN: at line 20
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang-linker-wrapper --wrapper-verbose --device-linker=amdgcn-amd-amdhsa=-v --device-compiler=-v --emit-fatbin-only --linker-path=/usr/bin/ld /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper-hip-no-rdc.c.tmp.out -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper-hip-no-rdc.c.tmp.hipfb 2>&1 | /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Driver/linker-wrapper-hip-no-rdc.c --check-prefix=CMD-LINUX
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang-linker-wrapper --wrapper-verbose --device-linker=amdgcn-amd-amdhsa=-v --device-compiler=-v --emit-fatbin-only --linker-path=/usr/bin/ld /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper-hip-no-rdc.c.tmp.out -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper-hip-no-rdc.c.tmp.hipfb
# note: command had no output on stdout or stderr
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Driver/linker-wrapper-hip-no-rdc.c --check-prefix=CMD-LINUX
# .---command stderr------------
# | FileCheck error: '<stdin>' is empty.
# | FileCheck command line:  /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Driver/linker-wrapper-hip-no-rdc.c --check-prefix=CMD-LINUX
# `-----------------------------
# error: command failed with exit status: 2

--

Clang.Driver/linker-wrapper-image.c
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 6
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Driver/linker-wrapper-image.c -triple x86_64-unknown-linux-gnu -emit-obj -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper-image.c.tmp.elf.o
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Driver/linker-wrapper-image.c -triple x86_64-unknown-linux-gnu -emit-obj -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper-image.c.tmp.elf.o
# note: command had no output on stdout or stderr
# RUN: at line 8
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/llvm-offload-binary -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper-image.c.tmp.out --image=file=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper-image.c.tmp.elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/llvm-offload-binary -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper-image.c.tmp.out --image=file=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper-image.c.tmp.elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70
# note: command had no output on stdout or stderr
# RUN: at line 9
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Driver/linker-wrapper-image.c -triple x86_64-unknown-linux-gnu -emit-obj -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper-image.c.tmp.o    -fembed-offload-object=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper-image.c.tmp.out
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Driver/linker-wrapper-image.c -triple x86_64-unknown-linux-gnu -emit-obj -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper-image.c.tmp.o -fembed-offload-object=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper-image.c.tmp.out
# note: command had no output on stdout or stderr
# RUN: at line 11
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang-linker-wrapper --print-wrapped-module --dry-run --host-triple=x86_64-unknown-linux-gnu    --linker-path=/usr/bin/ld /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper-image.c.tmp.o -o a.out 2>&1 | /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Driver/linker-wrapper-image.c --check-prefixes=OPENMP,OPENMP-ELF
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang-linker-wrapper --print-wrapped-module --dry-run --host-triple=x86_64-unknown-linux-gnu --linker-path=/usr/bin/ld /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper-image.c.tmp.o -o a.out
# note: command had no output on stdout or stderr
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Driver/linker-wrapper-image.c --check-prefixes=OPENMP,OPENMP-ELF
# .---command stderr------------
# | /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Driver/linker-wrapper-image.c:18:16: error: OPENMP-ELF: expected string not found in input
# | // OPENMP-ELF: @__start_llvm_offload_entries = external hidden constant [0 x %struct.__tgt_offload_entry]
# |                ^
# | <stdin>:1:1: note: scanning from here
# |  "/usr/bin/ld" /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper-image.c.tmp.o -o a.out
# | ^
# | 
# | Input file: <stdin>
# | Check file: /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Driver/linker-wrapper-image.c
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |           1:  "/usr/bin/ld" /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper-image.c.tmp.o -o a.out 
# | check:18     X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1

--

Clang.Driver/linker-wrapper.c
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 10
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Driver/linker-wrapper.c -triple x86_64-unknown-linux-gnu -emit-obj -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper.c.tmp.elf.o
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Driver/linker-wrapper.c -triple x86_64-unknown-linux-gnu -emit-obj -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper.c.tmp.elf.o
# note: command had no output on stdout or stderr
# RUN: at line 11
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Driver/linker-wrapper.c -triple nvptx64-nvidia-cuda -emit-llvm-bc -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper.c.tmp.nvptx.bc
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Driver/linker-wrapper.c -triple nvptx64-nvidia-cuda -emit-llvm-bc -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper.c.tmp.nvptx.bc
# note: command had no output on stdout or stderr
# RUN: at line 12
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Driver/linker-wrapper.c -triple amdgcn-amd-amdhsa -emit-llvm-bc -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper.c.tmp.amdgpu.bc
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Driver/linker-wrapper.c -triple amdgcn-amd-amdhsa -emit-llvm-bc -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper.c.tmp.amdgpu.bc
# note: command had no output on stdout or stderr
# RUN: at line 13
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Driver/linker-wrapper.c -triple spirv64-unknown-unknown -emit-llvm-bc -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper.c.tmp.spirv.bc
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Driver/linker-wrapper.c -triple spirv64-unknown-unknown -emit-llvm-bc -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper.c.tmp.spirv.bc
# note: command had no output on stdout or stderr
# RUN: at line 15
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/llvm-offload-binary -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper.c.tmp.out    --image=file=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper.c.tmp.elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70    --image=file=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper.c.tmp.elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/llvm-offload-binary -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper.c.tmp.out --image=file=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper.c.tmp.elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70 --image=file=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper.c.tmp.elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70
# note: command had no output on stdout or stderr
# RUN: at line 18
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Driver/linker-wrapper.c -triple x86_64-unknown-linux-gnu -emit-obj -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper.c.tmp.o -fembed-offload-object=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper.c.tmp.out
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Driver/linker-wrapper.c -triple x86_64-unknown-linux-gnu -emit-obj -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper.c.tmp.o -fembed-offload-object=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper.c.tmp.out
# note: command had no output on stdout or stderr
# RUN: at line 19
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run    --linker-path=/usr/bin/ld /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper.c.tmp.o -o a.out 2>&1 | /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Driver/linker-wrapper.c --check-prefix=NVPTX-LINK
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run --linker-path=/usr/bin/ld /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper.c.tmp.o -o a.out
# note: command had no output on stdout or stderr
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Driver/linker-wrapper.c --check-prefix=NVPTX-LINK
# .---command stderr------------
# | /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Driver/linker-wrapper.c:25:16: error: NVPTX-LINK: expected string not found in input
# | // NVPTX-LINK: clang{{.*}} -o {{.*}}.img -dumpdir a.out.nvptx64.sm_70.img. --target=nvptx64-nvidia-cuda -march=sm_70 {{.*}}.o {{.*}}.o
# |                ^
# | <stdin>:1:1: note: scanning from here
# |  "/usr/bin/ld" /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper.c.tmp.o -o a.out
# | ^
# | 
# | Input file: <stdin>
# | Check file: /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Driver/linker-wrapper.c
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |           1:  "/usr/bin/ld" /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/linker-wrapper.c.tmp.o -o a.out 
# | check:25     X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1

--

Clang.Driver/offload-packager.c
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 6
rm -rf /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/offload-packager.c.tmp && mkdir -p /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/offload-packager.c.tmp
# executed command: rm -rf /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/offload-packager.c.tmp
# note: command had no output on stdout or stderr
# executed command: mkdir -p /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/offload-packager.c.tmp
# note: command had no output on stdout or stderr
# RUN: at line 7
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Driver/offload-packager.c -triple x86_64-unknown-linux-gnu -emit-obj -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/offload-packager.c.tmp/elf.o
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/Driver/offload-packager.c -triple x86_64-unknown-linux-gnu -emit-obj -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/offload-packager.c.tmp/elf.o
# note: command had no output on stdout or stderr
# RUN: at line 10
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/llvm-offload-binary -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/offload-packager.c.tmp/package.out    --image=file=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/offload-packager.c.tmp/elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70    --image=file=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/offload-packager.c.tmp/elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_80    --image=file=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/offload-packager.c.tmp/elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx908    --image=file=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/offload-packager.c.tmp/elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx90a    --image=file=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/offload-packager.c.tmp/elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx90c
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/llvm-offload-binary -o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/offload-packager.c.tmp/package.out --image=file=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/offload-packager.c.tmp/elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70 --image=file=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/offload-packager.c.tmp/elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_80 --image=file=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/offload-packager.c.tmp/elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx908 --image=file=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/offload-packager.c.tmp/elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx90a --image=file=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/offload-packager.c.tmp/elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx90c
# note: command had no output on stdout or stderr
# RUN: at line 16
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/llvm-offload-binary /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/offload-packager.c.tmp/package.out    --image=file=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/offload-packager.c.tmp/sm_70.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70    --image=file=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/offload-packager.c.tmp/gfx908.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx908
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/llvm-offload-binary /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/offload-packager.c.tmp/package.out --image=file=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/offload-packager.c.tmp/sm_70.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70 --image=file=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/offload-packager.c.tmp/gfx908.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx908
# note: command had no output on stdout or stderr
# RUN: at line 19
diff /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/offload-packager.c.tmp/sm_70.o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/offload-packager.c.tmp/elf.o
# executed command: diff /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/offload-packager.c.tmp/sm_70.o /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/offload-packager.c.tmp/elf.o
# .---command stderr------------
# | Error: 'diff' command failed, [Errno 2] No such file or directory: '/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/test/Driver/Output/offload-packager.c.tmp/sm_70.o'
# `-----------------------------
# error: command failed with exit status: 1

--

If these failures are unrelated to your changes (for example tests are broken or flaky at HEAD), please open an issue at https://github.com/llvm/llvm-project/issues and add the infrastructure label.

@jhuber6 jhuber6 self-requested a review November 25, 2025 00:06
Copy link
Contributor

@jhuber6 jhuber6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with this in principle, but

Copy link
Contributor

@jhuber6 jhuber6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm okay with these changes, now we just need the few changes to make sure that everything still works with the new version. Check all the uses of these fields and we probably want an obj2yaml support for multiple entries so we can test it. Realistically you just need to update the extractOffloadFiles to additionally extract files within the same header.

uint64_t EntrySize; // Size of the metadata entry in bytes.
uint64_t Size; // Size in bytes of this entire binary.
uint64_t EntriesOffset; // Offset in bytes to the start of entries block.
uint64_t EntriesCount; // Number of metadata entries in the binary.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm okay with changing this, it wasn't really used for anything but a sanity check during parsing

@YuriPlyakhin
Copy link
Contributor Author

I'm okay with these changes, now we just need the few changes ...

Thank you for quick feedback, Joseph, I'll continue updating this PR with the further changes.

@YuriPlyakhin
Copy link
Contributor Author

FYI: I'm now updating OffloadBinary.cpp (OffloadBinary::create, OffloadBinary::write, etc..) to support new format.

@jhuber6
Copy link
Contributor

jhuber6 commented Nov 26, 2025

FYI: I'm now updating OffloadBinary.cpp (OffloadBinary::create, OffloadBinary::write, etc..) to support new format.

Yeah, we'll probably just want to make the interface take an array reference, possibly a helper that takes a single one and turns it into an array of one for convenience

Copy link
Contributor

@jhuber6 jhuber6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if we should keep the accessor methods to all take a single image, so the extract code just returns an array of these. You'd need to make sure the reference stays alive but it might be simpler that way, I don't think the interface handles this well, like for checking the image kind.

OffloadKind getOffloadKind() const { return Entries[0].first->TheOffloadKind; }
uint32_t getVersion() const { return TheHeader->Version; }
uint32_t getFlags() const { return TheEntry->Flags; }
uint32_t getFlags() const { return Entries[0].first->Flags; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this has any users, we can and should change the interface

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this getter for now.

StringRef getArch() const { return getString("arch"); }
StringRef getImage() const {
return StringRef(&Buffer[TheEntry->ImageOffset], TheEntry->ImageSize);
return StringRef(&Buffer[Entries[0].first->ImageOffset], Entries[0].first->ImageSize);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably want an index, can initialize it to zero for backward compat.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added an index but did not initialize yet.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we won't need an index here, that's what we can hopefully avoid

MapVector<StringRef, StringRef> StringData;
/// Location of the metadata entries within the binary mapped to
/// the key-value string data.
SmallVector<std::pair<const Entry *, StringMap>, 1> Entries;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't decide if this should be two vectors that take the same index

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If OffloadBinary objects share the same header and each corresponds to a single Entry/Image, then we do not need vectors.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd want to be compatible with the appended form as well, since that occurs if people use relocatable links or other merging methods

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, basically, each OffloadBinary would be something like this in terms of data:

TheHeader  <-- shared somehow between all OffloadBinary objects
Buffer  <-- shared somehow between all OffloadBinary objects
Vector<Entry> <-- identical for all OffloadBinary objects
Vector<StringMap> <-- identical for all OffloadBinary objects
Index <-- initialized to consecutive numbers when extracting OffloadBinaries, so that getters would work as before for compatiblity.

Is this what you have in mind?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now I think we return references, but there's an explicit copy method? In the copy method would need to copy the header, but references can just use the existing one or something. The extracted interface isn't the binary serialized one so we can probably do a little magic if needed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, there is an explicit deep copy method. ok, I'll try this also.

const StringEntry *StringMapBegin = reinterpret_cast<const StringEntry *>(
&Buffer[TheEntry->StringOffset]);
StringMap Strings;
for (uint64_t SI = 0, SE = TheEntry->NumStrings; SI != SE; ++SI) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just take a reference to the StringData and keep the old handling?

Copy link
Contributor Author

@YuriPlyakhin YuriPlyakhin Dec 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand. It is old handling. We still read each StringEntry one-time. 2 loops allow to split StringEntries in accordance with Entries they belong to.
If we read just all StringEntries as before to a single StringMap for all entries, we need to keep start and end indexes to be able to know which key-value pairs correspond to which entry, is it what you suggest?

@YuriPlyakhin
Copy link
Contributor Author

I'm wondering if we should keep the accessor methods to all take a single image, so the extract code just returns an array of these. You'd need to make sure the reference stays alive but it might be simpler that way, I don't think the interface handles this well, like for checking the image kind.

Could you please elaborate, I'm not sure I understand what you mean exactly... Maybe you can just provide a sketch of the interface that you have in mind?

@jhuber6
Copy link
Contributor

jhuber6 commented Dec 2, 2025

I'm wondering if we should keep the accessor methods to all take a single image, so the extract code just returns an array of these. You'd need to make sure the reference stays alive but it might be simpler that way, I don't think the interface handles this well, like for checking the image kind.

Could you please elaborate, I'm not sure I understand what you mean exactly... Maybe you can just provide a sketch of the interface that you have in mind?

The extract interface already returns a vector of these binaries. We could keep the same extract interface so we don't need to change the get routines to index. The main difference is that these would be slices that share a header so you'd need to manage the memory or create new buffers by copying the header.

@YuriPlyakhin
Copy link
Contributor Author

I'm wondering if we should keep the accessor methods to all take a single image, so the extract code just returns an array of these. You'd need to make sure the reference stays alive but it might be simpler that way, I don't think the interface handles this well, like for checking the image kind.

Could you please elaborate, I'm not sure I understand what you mean exactly... Maybe you can just provide a sketch of the interface that you have in mind?

The extract interface already returns a vector of these binaries. We could keep the same extract interface so we don't need to change the get routines to index. The main difference is that these would be slices that share a header so you'd need to manage the memory or create new buffers by copying the header.

I see, interesting idea, I'll try.

@YuriPlyakhin
Copy link
Contributor Author

YuriPlyakhin commented Dec 2, 2025

I updated OffloadBinary.h in accordance with how I understand your idea so far. Not a complete of course, just a few changes to see if we are aligning our understanding.

const OffloadBinary::Header *Header = *HeaderOrErr;

switch (Header->Version) {
case 1: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The version just changes the count, right? Might be easier to just initialize the count to one and set it to the proper size if the version is version 2. That way we should be able to share the code


// This parsing should never fail because it has already been parsed.
auto NewBinaryOrErr = OffloadBinary::create(*Buffer);
auto NewBinaryOrErr = OffloadBinary::createV1(*Buffer);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need a versioned create method, everything should use the new version after this. Realistically we probably just want an overload that takes a single one and another that takes an array. The old function just calls the new one with an array of size one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants